
library(testthat)
library(blma)
library(tictoc)
library(parallel)

cores <- detectCores()

test_that('eyeData produces correct results ZE', {
	set.seed(2019)
	eyeData <- get_eyeData()
    vy <- eyeData$vy
    mX <- eyeData$mX
    p <- ncol(mX)
    tic('eyeData produces correct results ZE')
    result <- sampler(100000, vy, mX, prior='ZE', modelprior='beta-binomial', modelpriorvec=c(1, p), cores=cores)
    toc()
    expect_equal(result$vinclusion_prob, 
c(
0.003210000000000000,0.004930000000000000,0.001490000000000000,
0.001730000000000000,0.002620000000000000,0.003470000000000000,
0.001390000000000000,0.003670000000000000,0.001770000000000000,
0.002050000000000000,0.057650000000000000,0.003180000000000000,
0.002730000000000000,0.001890000000000000,0.001510000000000000,
0.003110000000000000,0.001390000000000000,0.001630000000000000,
0.002450000000000000,0.001310000000000000,0.001460000000000000,
0.001700000000000000,0.001970000000000000,0.001420000000000000,
0.001400000000000000,0.003430000000000000,0.001530000000000000,
0.009630000000000000,0.001270000000000000,0.003470000000000000,
0.004070000000000000,0.001350000000000000,0.002560000000000000,
0.001750000000000000,0.001690000000000000,0.005790000000000000,
0.001460000000000000,0.002430000000000000,0.001550000000000000,
0.001560000000000000,0.001530000000000000,0.039820000000000001,
0.001680000000000000,0.001570000000000000,0.001370000000000000,
0.001890000000000000,0.001550000000000000,0.001460000000000000,
0.002270000000000000,0.005690000000000000,0.001610000000000000,
0.003560000000000000,0.001570000000000000,0.009960000000000000,
0.009299999999999999,0.001200000000000000,0.001720000000000000,
0.002090000000000000,0.002510000000000000,0.010019999999999999,
0.001300000000000000,0.027560000000000001,0.002050000000000000,
0.002320000000000000,0.001990000000000000,0.007060000000000000,
0.001700000000000000,0.001570000000000000,0.001360000000000000,
0.001940000000000000,0.013469999999999999,0.001460000000000000,
0.001570000000000000,0.001960000000000000,0.001630000000000000,
0.017649999999999999,0.001700000000000000,0.002720000000000000,
0.001350000000000000,0.001780000000000000,0.001430000000000000,
0.001440000000000000,0.001590000000000000,0.001690000000000000,
0.004440000000000000,0.001740000000000000,0.170880000000000004,
0.001950000000000000,0.002240000000000000,0.021110000000000000,
0.001350000000000000,0.005040000000000000,0.002750000000000000,
0.001190000000000000,0.001650000000000000,0.004250000000000000,
0.001820000000000000,0.001380000000000000,0.013420000000000000,
0.001940000000000000,0.002220000000000000,0.009050000000000001,
0.001250000000000000,0.003260000000000000,0.001550000000000000,
0.001760000000000000,0.003250000000000000,0.003580000000000000,
0.023279999999999999,0.008170000000000000,0.003900000000000000,
0.015250000000000000,0.003810000000000000,0.001770000000000000,
0.001710000000000000,0.001420000000000000,0.003510000000000000,
0.001400000000000000,0.001550000000000000,0.001540000000000000,
0.001670000000000000,0.001280000000000000,0.006630000000000000,
0.002760000000000000,0.007750000000000000,0.001440000000000000,
0.009719999999999999,0.001560000000000000,0.001630000000000000,
0.001560000000000000,0.001680000000000000,0.008399999999999999,
0.001350000000000000,0.007770000000000000,0.004560000000000000,
0.024140000000000002,0.002420000000000000,0.001510000000000000,
0.001750000000000000,0.009800000000000000,0.010659999999999999,
0.001510000000000000,0.001840000000000000,0.001390000000000000,
0.001630000000000000,0.006990000000000000,0.007930000000000000,
0.003400000000000000,0.001370000000000000,0.001530000000000000,
0.002740000000000000,0.002450000000000000,0.951949999999999963,
0.005460000000000000,0.031899999999999998,0.001590000000000000,
0.008279999999999999,0.007700000000000000,0.014449999999999999,
0.002070000000000000,0.005440000000000000,0.005910000000000000,
0.002640000000000000,0.015810000000000001,0.002140000000000000,
0.001950000000000000,0.001290000000000000,0.002270000000000000,
0.001280000000000000,0.003580000000000000,0.001610000000000000,
0.024559999999999998,0.003650000000000000,0.002000000000000000,
0.003360000000000000,0.002270000000000000,0.006390000000000000,
0.001370000000000000,0.002250000000000000,0.761009999999999964,
0.057459999999999997,0.018050000000000000,0.007110000000000000,
0.004210000000000000,0.746240000000000014,0.001880000000000000,
0.043420000000000000,0.009540000000000000,0.003280000000000000,
0.003130000000000000,0.001720000000000000,0.001510000000000000,
0.001280000000000000,0.001540000000000000,0.001300000000000000,
0.003590000000000000,0.001710000000000000,0.002270000000000000,
0.003790000000000000,0.052310000000000002
)
, tolerance = 1e-8)
})